const http = require('http')

// get请求
// http.get('http://localhost:8000', (res) => {
//   res.on('data', (data) => {
//     console.log(data)
//     const dataString = data.toString()
//     console.log(typeof dataString)
//     const dataInfo = JSON.parse(dataString)
//     console.log(typeof dataInfo)
//   })
// })

const req = http.request(
  {
    method: 'POST',
    hostname: 'localhost',
    port: 8000,
  },
  (res) => {
    res.on('data', (data) => {
      // console.log(data)
      const dataString = data.toString()
      console.log(dataString)
      const dataInfo = JSON.parse(dataString)
      console.log(dataInfo)
    })
  }
)
req.end()
